//    Copyright (C) 2013  <lugocreation@gmail.com>
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
package org.jpgolay.me.family;

import java.util.ArrayList;
import java.util.Iterator;
import org.jpgolay.me.persistence.ObjectCRUD;

// Referenced classes of package org.jpgolay.me.family:
//            Family
public class FamilyUtility {

    public FamilyUtility() {
        crud = new ObjectCRUD();
    }

    public String[] getItemFamilyIdList() {
        return selectItemFamilyIdList();
    }

    private String[] selectItemFamilyIdList() {
        String data[] = (String[]) null;
        java.util.Collection list = crud.readAll(null, 12);
        if (list != null) {
            Family family = null;
            ArrayList arrayList = new ArrayList(list);
            data = new String[arrayList.size()];
            Iterator it = arrayList.iterator();
            for (int i = 0; it.hasNext(); i++) {
                family = (Family) it.next();
                data[i] = family.getId();
            }

            return data;
        } else {
            return null;
        }
    }

    public String[] getCustomerFamilyIdList() {
        return selectCustomerFamilyIdList();
    }

    private String[] selectCustomerFamilyIdList() {
        String data[] = (String[]) null;
        java.util.Collection list = crud.readAll(null, 46);
        if (list != null) {
            Family family = null;
            ArrayList arrayList = new ArrayList(list);
            data = new String[arrayList.size()];
            Iterator it = arrayList.iterator();
            for (int i = 0; it.hasNext(); i++) {
                family = (Family) it.next();
                data[i] = family.getId();
            }

            return data;
        } else {
            return null;
        }
    }

    public String[] getSupplierFamilyIdList() {
        return selectSupplierFamilyIdList();
    }

    private String[] selectSupplierFamilyIdList() {
        String data[] = (String[]) null;
        java.util.Collection list = crud.readAll(null, 10);
        if (list != null) {
            Family family = null;
            ArrayList arrayList = new ArrayList(list);
            data = new String[arrayList.size()];
            Iterator it = arrayList.iterator();
            for (int i = 0; it.hasNext(); i++) {
                family = (Family) it.next();
                data[i] = family.getId();
            }

            return data;
        } else {
            return null;
        }
    }

    public String[] getSalesPersonFamilyIdList() {
        return selectSalesPersonFamilyIdList();
    }

    private String[] selectSalesPersonFamilyIdList() {
        String data[] = (String[]) null;
        java.util.Collection list = crud.readAll(null, 39);
        if (list != null) {
            Family family = null;
            ArrayList arrayList = new ArrayList(list);
            data = new String[arrayList.size()];
            Iterator it = arrayList.iterator();
            for (int i = 0; it.hasNext(); i++) {
                family = (Family) it.next();
                data[i] = family.getId();
            }

            return data;
        } else {
            return null;
        }
    }
    private ObjectCRUD crud;
}
